import { ModalController } from '@ionic/angular';
import { ImgSlidePage } from './../slides-imgage/img-slide.page';
import { Component, Input, OnInit } from '@angular/core';

@Component({
  selector: 'app-company-info',
  templateUrl: './company-info.component.html',
  styleUrls: ['./company-info.component.scss'],
})
export class CompanyInfoComponent implements OnInit {
  @Input() tagData: any;
  constructor(
    private modalCtrl: ModalController,

  ) { }

  ngOnInit() { }
  openImg() {
    if (this.tagData.data.data.imgUrl) {
      this.openImage(this.tagData.data.data.imgUrl);
    } else if (this.tagData.data.data.imageUrl) {
      this.openImage(this.tagData.data.data.imageUrl);
    }
  }
  // 打开图片展示框，滑动展示
  async openImage(url) {
    const urlArray = [url];
    let pageTitle = '';
    if (this.tagData.data.data.openImagePageTitle) {
      pageTitle = this.tagData.data.data.openImagePageTitle;
    }

    const value = { img: urlArray, index: 1 };
    const modal = await this.modalCtrl.create({
      component: ImgSlidePage,
      componentProps: { value: JSON.stringify(value), title: pageTitle }
    });
    return await modal.present();
  }
}
